#ifndef _MUTEX_HPP_
#define _MUTEX_HPP_

#include <pthread.h>

class Mutex
{
    public:
        Mutex()
        {
            pthread_mutex_init(&_mutex,nullptr);
        }
        ~Mutex()
        {
            pthread_mutex_destroy(&_mutex);
        }
        void Lock()
        {
            pthread_mutex_lock(&_mutex);
        }
        void Unlock()
        {
            pthread_mutex_unlock(&_mutex);
        }
        pthread_mutex_t* GetMutex()
        {
            return &(_mutex);
        }
    private:
        pthread_mutex_t _mutex;
    };

    class Lock_Manager
    {
        public:
            Lock_Manager(Mutex& mutex)
                :_mutex(mutex)
            {
                _mutex.Lock();
            }
            ~Lock_Manager()
            {
                _mutex.Unlock();
            }
        private:
            Mutex& _mutex;
    };

#endif